package com.lc.hot100.lc19;

import com.lc.utils.ListNode;

public class Main {

}

class Solution {
    public ListNode removeNthFromEnd(ListNode head, int n) {
        ListNode t = new ListNode(0,head);
        ListNode fast = t, slow = t;
        
        while(n > 0) {
        	n --;
        	fast = fast.next;
        }
        
        while(fast.next != null) {
        	fast = fast.next;
        	slow = slow.next;
        }
        slow.next = slow.next.next;
        
        return t.next;
    }
}
